package au.edu.swin.MelbourneMap;

import java.util.*;
import java.awt.Color;
import java.awt.geom.*;

/**
 * Data structure to define a map region comprised of a Path2D of points. 
 *
 * @author  Alexis Wellavize (s/n: 6033482)<br/>
 *           Dotan Tamir (s/n: 6532969)
 * @since   v1, created:  17/09/2012
 * @version v2, modified:  22/09/2012
 *
 */
 
class Region
{
    /// Name of region
    private String regionName;
    /// Path2D for region
    private Path2D path;
    /// x,y coordinates
    private Double x, y;
    /// easting and northing coordinates
    private Double easting, northing;
    /// Minimum and maximum easting values
    private Double minE, maxE;
    /// Minimum and maximum northing values
    private Double minN, maxN;
    /// Region Visibility
    private boolean visibility;
    // Region colour
    private Color color;
        
    // Overloaded constructor
    public Region( String regionName )
    {
    	this.regionName = regionName;
    }
    
    // Accessor methods
    public String getName()
    {
    	return regionName;
    }
    
    public Path2D getPath()
    {
        return path;
    }
    
    public Double getMinE()
    {
        return minE;
    }
    
    public Double getMaxE()
    {
        return maxE;
    }
    
    public Double getMinN()
    {
        return minN;
    }
    
    public Double getMaxN()
    {
        return maxN;
    }
    
    public boolean getVisibility()
    {
        return visibility;
    }
    
	public Color getColor()
    {
		return color;
	}    
    
    // Mutator methods
    public void setName( String regionName )
    {
    	this.regionName = regionName;
    }
    
    public void setPath( Path2D path )
    {
    	this.path = path;
    } 
    
    public void setMinE( Double minE )
    {
    	this.minE = minE;
    }
    
    public void setMaxE( Double maxE )
    {
    	this.maxE = maxE;
    }
    
    public void setMinN( Double minN )
    {
    	this.minN = minN;
    }

    public void setMaxN( Double maxN )
    {
    	this.maxN = maxN;
    }
    
    public void setVisibility( boolean visibility )
    {
        this.visibility = visibility;
    }
    
	public void setColor( Color color )
    {
		this.color = color;
	}    
    
    /**
     *
     * Reads Australian Map Grid data for region.
     * Stops when line "end" is read.
     * @param input open file which has just read the number
     *
     */
    public void read( ArrayList<Point2D> points )
    {
        path = new Path2D.Double();
		
		for ( int i = 0; i < points.size(); i++ )
		{
			x = ( points.get(i).getX() );
			y = ( points.get(i).getY() );
		    
		    if ( i == 0 )
                path.moveTo( x, y );
		    else if(i ==points.size())
		    {
		    	path.lineTo( x, y );
		    	path.closePath();
		    	}
		    else
                path.lineTo( x, y );  

		}
    }
}